package org.nox.helloseries.web.client.metier;

import com.google.gwt.user.client.rpc.IsSerializable;

public enum VersionWeb
    implements IsSerializable
{
    VO( "",0 ), VOSTFR( "VOSTFR",1 ), VF( "FRENCH",2 );

    private String value;

    private int index;
    
    
    VersionWeb( String value, int index )
    {
        this.value = value;
        this.index=index;
    }

    public String getValue()
    {
        return value;
    }

    public int getIndex() {
		return index;
	}
    
    public static VersionWeb fromValue( String value )
        throws IllegalArgumentException
    {
        if ( value == null )
        {
            throw new IllegalArgumentException( "Mapping échoué : valeur null" );
        }
        for ( VersionWeb version : values() )
        {
            if ( version.getValue().toLowerCase().equals( value.toLowerCase().trim() ) )
            {
                return version;
            }
        }
        throw new IllegalArgumentException( "Mapping échoué " + value );
    }

    public static boolean checkValue( String value )
    {
        String format = value.toLowerCase().trim();
        return format.equals( VO.getValue().toLowerCase() ) || format.equals( VF.getValue().toLowerCase() )
            || format.equals( VOSTFR.getValue().toLowerCase() );
    }

    public boolean isVO()
    {
        return this.equals( VO );
    }

    public boolean isVOSTFR()
    {
        return this.equals( VOSTFR );
    }

    public boolean isVF()
    {
        return this.equals( VF );
    }
}
